<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>场地信息管理</title>
    <link rel="stylesheet" type="text/css" href="/site_jquery-easyui-1.3.3/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/site_jquery-easyui-1.3.3/themes/icon.css">
    <script type="text/javascript" src="/site_jquery-easyui-1.3.3/jquery.min.js"></script>
    <script type="text/javascript" src="/site_jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/site_jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
        var url;
        function search(){
            $("#dg").datagrid('load',{
                "status":$("#status").combobox("getValue"),
                "whenTime":$("#whenTime").combobox("getValue"),
                "applicationTime":$("#applicationTime").datebox('getValue')
            });
        };


        function openAddDialog(){
            $("#dlg").dialog("open").dialog("setTitle","登记新场地信息");
            url="/siteInformation/addSiteInfo";
        };


        function saveSite(){
            $("#fm").form("submit",{
                url:url,
                success:function(result){
                    var result=eval('('+result+')');
                    if(result.success){
                        $.messager.alert("系统提示","登记成功");
                        closeDialog();
                        $("#dg").datagrid("reload");
                    }else{
                        $.messager.alert("系统提示","登记失败");
                        return;
                    }
                }
            });
        };

        function openlookDialog(){
            var selectedRows=$("#dg").datagrid('getSelections');
            if(selectedRows.length!=1){
                $.messager.alert("系统提示","请选择一条要查看的数据！");
                return;
            }
            var row=selectedRows[0];
            $("#dlg").dialog("open").dialog("setTitle","查看场地信息明细");
            $('#fm').form('load',row);
            $('#btn').linkbutton('disable');
            $('#siteStatus').combo('readonly', true);
        }

        function openModifyDialog(){

            var selectedRows=$("#dg").datagrid('getSelections');
            if(selectedRows.length!=1){
                $.messager.alert("系统提示","请选择一条要取消预约的数据！");
                return;
            }
            var row=selectedRows[0];
            if(row.status!="正在审核"){
                $.messager.alert("系统提示","请选择一条正在审核的数据！");
                return;
            }
            $.messager.confirm("系统提示","您确认要取消预约<font color=blue>"+row.name+"  "+row.position+"  "+row.applicationTime+"  "+row.whenTime+"</font>这个场地吗？",function(r){
                if(r){
                    $.post("/siteReservation/changeMyYuyueSatus",{applicationTime:row.applicationTime,whenTime:row.whenTime,userId:row.userId,siteId:row.siteId},function(result){
                        if(result.success){
                            $.messager.alert("系统提示","取消成功！");
                            $("#dg").datagrid("reload");
                        }else{
                            $.messager.alert("系统提示","取消失败！");
                        }
                    },"json");
                }
            });

        }

        function closeDialog(){
            $("#dlg").dialog("close");

            $("#fm").form("clear");
            $('#btn').linkbutton('enable');
            $('#siteStatus').combo('readonly', false);

        };

    </script>
</head>
<body style="margin:1px;">
<table id="dg" title="我的预约信息" class="easyui-datagrid"
       fitColumns="true" pagination="true" rownumbers="true" singleSelect="true"
       url="/siteReservation/findMySiteReservation" fit="true" toolbar="#tb">
    <thead>
    <tr>
        <!--  private Integer siteYyId;
    private Integer userId;
    private Integer siteId;
    @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
    private Date applicationTime;
    @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
    private Date returnTime;
    private String whenTime;
    private String status;
    private Integer amdinId;
    private String reason;
-->
        <th field="siteYyId" width="50" align="center">编号</th>
        <th field="name" width="60" align="center">场地名称</th>
        <th field="position" width="90" align="center">场地位置</th>
        <th field="applicationTime" width="85" align="center" >租借日期</th>
        <th field="whenTime" width="80" align="center" >时间段</th>
        <th field="status" width="80" align="center">状态</th>
        <th field="price" width="60" align="center">价格</th>


    </tr>
    </thead>
</table>
<div id="tb">
    <div>

        <a href="javascript:openModifyDialog()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">取消预约</a>

    </div>
    <div>

        &nbsp;状态：&nbsp;<input class="easyui-combobox" name="status" id="status" style="width: 135px;"
                                data-options="
                                    url:'/siteReservation/findStatus',
									valueField:'id',
									textField:'text',
									panelHeight:'auto',

                                    ">
        &nbsp;申请日期：&nbsp;<input class="easyui-datebox" name="applicationTime" id="applicationTime" style="width: 135px;"></input>
        &nbsp;时间段：&nbsp;<select id="whenTime" class="easyui-combobox" name="whenTime" panelHeight="auto" style="width: 135px;">
        <option value="" selected>请选择:</option>
        <option value="08:10-09:45">08:10-09:45</option>
        <option value="10:15-11:50">10:15-11:50</option>
        <option value="14:30-16:05">14:30-16:05</option>
        <option value="16:30-18:05">16:30-18:05</option>
    </select>

        <a href="javascript:search()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
    </div>
</div>

<div id="dlg" class="easyui-dialog" style="width: 680px;height:350px;"
     closed="true"  closable="false" buttons="#dlg-buttons">
    <form id="fm"  enctype="multipart/form-data"  method="post">
        <table >
            <!--
               private Integer siteId;
               private String name;
               private String position;
               private String purpose;
               private String status;
               private Double price;
               private Date changeDate;
               private Integer adminId;
               private String detail;
       -->
            <tr><td><input name="siteId" id="siteId" type="hidden"></td></tr>
            <tr>
                <td>场地名称：</td>
                <td>
                    <input class="easyui-textbox" name="name" id="siteName"></input>
                </td>
            </tr>

            <tr>
                <td>位置：</td>
                <td>
                    <input class="easyui-textbox" name="position" id="sitePosition"></input></td>
                </td>
            </tr>
            <tr>
                <td>用途：</td>
                <td>
                    <input class="easyui-textbox" name="purpose" id="sitePurpose"></input></td>
                </td>
            </tr>
            <tr>
                <td>价格：</td>
                <td><input type="text" class="easyui-numberbox" name="price" id="sitePrice" value="100" data-options="min:0,precision:2"></input>
                </td>
            </tr>
            <tr>
                <td>场地状态：</td>
                <td>
                    <select id="siteStatus" class="easyui-combobox" name="status" style="width:147px;">
                        <option value="可租借" selected>可租借</option>
                        <option value="维修">维修</option>
                        <option value="已租借">已租借</option>
                        <option value="报废">报废</option>
                        <option value="特殊用途">特殊用途</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td valign="top">场地详细描述：</td>
                <td colspan="8">
                    <textarea rows="5" cols="60" id="SiteDetail" name="detail"></textarea>
                </td>
            </tr>

        </table>
    </form>
</div>

<div id="dlg-buttons">
    <a href="javascript: saveSite()" id="btn" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
    <a href="javascript: closeDialog()" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
</div>
</body>
</html>